package cn.tedu.boot414.controller;

import cn.tedu.boot414.entity.Person;
import cn.tedu.boot414.mapper.PersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PersonController {
    @Autowired
    PersonMapper mapper;
    @RequestMapping("/insert")
    public void insert(@RequestBody Person person){
        System.out.println("person = " + person);
        mapper.insert(person);
    }

    @RequestMapping("/select")
    public List<Person> select(){
       List<Person> list= mapper.select();
       return list;
    }

    @RequestMapping("/delete")
    public void delete(int id){
        mapper.deleteById(id);
    }

    @RequestMapping("/selectById")
    public Person selectById(int id){
        return mapper.selectById(id);
    }

    @RequestMapping("/update")
    public void update(@RequestBody Person person){
        mapper.update(person);
    }
}
